<?php

/*
 * User form
 */
class UserForm extends sfForm
{
	/**
	 * Init items for User form
	 */
	public function setup()
	{
		$this->setWidgets(array(
			'intId' => new sfWidgetFormInputHidden(),
			'txtName' => new sfWidgetFormInput(array(), array('size' => 40, 'maxlength' => 50, 'style' => 'ime-mode:disabled;')),
			'txtMailAddress' => new sfWidgetFormInput(array(), array('size' => 40, 'maxlength' => 50, 'style' => 'ime-mode:disabled;')),
			'txtMailAddressConfirm' => new sfWidgetFormInput(array(), array('size' => 40, 'maxlength' => 50, 'style' => 'ime-mode:disabled;')),
			'txtPassword' => new sfWidgetFormInputPassword(array(), array('size' => 40, 'maxlength' => 50, 'style' => 'ime-mode:disabled;')),
			'txtPasswordConfirm' => new sfWidgetFormInputPassword(array(), array('size' => 40, 'maxlength' => 50, 'style' => 'ime-mode:disabled;')),
			'txtName' => new sfWidgetFormInput(array(), array('size' => 60, 'maxlength' => 100, 'style' => 'ime-mode:active;')),
			'radIsMale' => new sfWidgetFormSelectRadio(array('choices' => array(1 => 'Name', 2 => 'Nữ')), array('style' => 'display: inline; font-size: 10pt')),
			'txtTel1' => new sfWidgetFormInput(array(), array('size' => 10, 'maxlength' => 5, 'style' => 'ime-mode:disabled;')),
			'txtTel2' => new sfWidgetFormInput(array(), array('size' => 10, 'maxlength' => 4, 'style' => 'ime-mode:disabled;')),
			'txtBirthDay1' => new sfWidgetFormInput(array(), array('size' => 10, 'maxlength' => 3, 'style' => 'ime-mode:disabled;')),
			'txtBirthDay2' => new sfWidgetFormInput(array(), array('size' => 10, 'maxlength' => 4, 'style' => 'ime-mode:disabled;')),
			'txtBirthDay3' => new sfWidgetFormInput(array(), array('size' => 10, 'maxlength' => 4, 'style' => 'ime-mode:disabled;')),
			'txtFax1' => new sfWidgetFormInput(array(), array('size' => 10, 'maxlength' => 5, 'style' => 'ime-mode:disabled;')),
			'txtAddress' => new sfWidgetFormInput(array(), array('size' => 40, 'maxlength' => 50, 'style' => 'ime-mode:disabled;')),
			//'radIsAdmin' => new sfWidgetFormSelectRadio(array('choices' => array(1 => 'Name', 2 => 'Nữ')), 'default' => '1'), array('style' => 'display: inline; font-size: 10pt')),
		));

		$this->widgetSchema->setNameFormat('aryUser[%s]');

		$this->validatorSchema->setOption('allow_extra_fields', true);
		$this->validatorSchema->setOption('filter_extra_fields', false);

		$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

		parent::setup();
	}

	/**
	 * Get value for item name input
	 * @param string $strItem, string $strNull
	 * @return string
	 */
	public function getValue($strItem, $strNull = '')
	{
		return ($this[$strItem]->getValue() != NULL) ? htmlspecialchars($this[$strItem]->getValue()) : $strNull;
	}
}
